import request from '@/utils/request_zc'

export function getSaleOrderList ({
  page,
  limit,
  orderNo,
  customerName,
  deliveryStartDate,
  deliveryEndDate,
  applyStatus,
  applyUser,
  applyStartDate,
  applyEndDate,
  approveUser,
  approveStartDate,
  approveStatus,
  approveEndDate }) {
  return request({
    url: '/scm/sales/order/list',
    method: 'get',
    params: {
      page,
      limit,
      orderNo,
      customerName,
      deliveryStartDate,
      deliveryEndDate,
      applyStatus,
      applyUser,
      applyStartDate,
      applyEndDate,
      approveUser,
      approveStartDate,
      approveStatus,
      approveEndDate
    }
  })
}

export function editSaleOrder ({
  customerId,
  deliveryDate,
  detailList,
  id,
  remark,
}) {
  return request({
    url: '/scm/sales/order/edit',
    method: 'post',
    data: {
      customerId,
      deliveryDate,
      detailList,
      id,
      remark,
    }
  })
}

export function getApplyApproveUserList () {
  return request({
    url: '/sys/user/list',
    method: 'get'
  })
}

export function getSaleOrderDetailList ({ id }) {
  return request({
    url: `/scm/sales/order/detail/${id}`,
    method: 'get'
  })
}

export function addSaleOrder ({
  customerId,
  deliveryDate,
  detailList,
  remark,
}) {
  return request({
    url: '/scm/sales/order/add',
    method: 'post',
    data: {
      customerId,
      deliveryDate,
      detailList,
      remark,
    }
  })
}

export function delSaleOrder ({ ids }) {
  return request({
    url: '/scm/sales/order/del',
    method: 'post',
    data: {
      ids
    }
  })
}

export function editProductModeling (data) {
  return request({
    url: '/product/model/edit',
    method: 'post',
    data
  })
}

export function getCustomerList ({ page, limit, name, contact, category }) {
  return request({
    url: '/scm/customer/list',
    method: 'get',
    params: {
      page,
      limit,
      name,
      contact,
      category
    }
  })
}

export function addProductModeling (data) {
  return request({
    url: '/product/model/add',
    method: 'post',
    data
  })
}

export function getMaterialCategoryList () {
  return request({
    url: '/material/category/list',
    method: 'get'
  })
}

export function getMaterialList ({ pid }) {
  return request({
    url: '/wms/material/list',
    method: 'get',
    params: {
      pid
    }
  })
}
